const { Model, DataTypes, Sequelize } = require('sequelize')
const db = require('../core/db')
class Group extends Model {

}

Group.init({
  name: {
    type: DataTypes.STRING,
    validate: {
      notEmpty: {
        msg: '组名不能为空'
      },
      len: {
        args: [1, 16],
        msg: '组名不能超过16字符'
      }
    },
    comment:"组名"
  },
  key: {
    type: DataTypes.UUID,
    defaultValue:Sequelize.UUIDV4,
    comment:"每组对应的key,同个分组类型key唯一"
  },
  type: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment:"分组类型 1 表示默认分组，2表示自定义分组"
  },
  canDel: {
    type: DataTypes.BOOLEAN,
    defaultValue: false,
    comment:"是否能删除分组"
  }

}, {
  sequelize: db,
  modelName: 'Group' // 我们需要选择模型名称
})
module.exports = Group
